package com.air.ota.vo;

import com.air.ota.util.PBOCUtil;
import com.air.ota.util.PkgUtil;

public class UTKRegResultUplinkVO extends UTKBaseUplinkPgkVO{
	
	protected byte[] cardAppSequence;
	protected byte[] regSequence;
	protected byte[] regResult;
	protected byte[] cardRemain;
	protected byte[] cardTransSequence;
	protected byte[] pkgSequence;

	
	public UTKRegResultUplinkVO(byte[] cardSequence){
		super();
		this.cmdType = 0x05;
		
		cardAppSequence = new byte[8];
		regSequence = new byte[2];
		regResult = new byte[2];
		cardRemain = new byte[4];
		cardTransSequence = new byte[2];
		pkgSequence = new byte[4];
		
		
		super.cardSequence = cardSequence;
	}
	
	/**
	 * 应用序列号	8	HEX	
开通流水号	2	HEX	从0x0000开始；每次发送开通认证请求流水号加1；达到0xFFFF，再次发送开通认证请求后循环至0x0000。
开通结果	2	HEX	9000-开通成功
卡片余额	4	HEX	小端模式
卡交易序号	2	HEX	小端模式
报文流水号	4 	HEX	参见 7.2.1.1
随机数	4 	HEX 	
MAC 	4 	HEX 	MAC计算机制
	 */
	@Override
	public  void parse(byte[] pkg){
		super.parse(pkg);
		
		//System.arraycopy(pkg, 20, this.cmdLength, 0, 2);
		
		
		//int encCmdDataLength = pkg.length-23-8;//去头23byte，去mac和random8byte
		//encCmdData = new byte[encCmdDataLength];
		//System.arraycopy(pkg, 23, encCmdData, 0, encCmdDataLength);
		
		decryptCmdData();
		
		System.arraycopy(this.cmdData, 0, this.cardAppSequence, 0, 8);
		System.arraycopy(this.cmdData, 8, this.regSequence, 0, 2);
		System.arraycopy(this.cmdData, 10, this.regResult, 0, 2);
		System.arraycopy(this.cmdData, 12, this.cardRemain, 0, 4);
		System.arraycopy(this.cmdData, 16, this.cardTransSequence, 0, 2);
		System.arraycopy(this.cmdData, 18, this.pkgSequence, 0, 4);
		PkgUtil.setCurrentPkgSequence(pkgSequence);
	}
	
	
	public byte[] getCardAppSequence() {
		return cardAppSequence;
	}



	public byte[] getRegSequence() {
		return regSequence;
	}



	public byte[] getRegResult() {
		return regResult;
	}

	public byte[] getCardRemain() {
		return cardRemain;
	}


	public byte[] getCardTransSequence() {
		return cardTransSequence;
	}

	public byte[] getPkgSequence() {
		return pkgSequence;
	}
	
	
	
}
